<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex align-center benben-position-layout flex search_flex_0"
        :style="{height:(100+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex align-center flex-sub search_fd0_0'>
          <!-- <text class='fu-iconfont2  search_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">&#xE794;</text> -->
            <image class='search_fd0_0_c0' mode="aspectFit" :src='STATIC_URL+"leftb.png"'></image>
          <view class='flex align-center search_fd0_0_c1'>
            <image class='search_fd0_0_c1_c0' mode="aspectFit" :src='STATIC_URL+"195.png"'></image>
            <input class='search_fd0_0_c1_c1' type="text" :placeholder="`搜索`" v-model="keyword" confirm-type="done" :maxlength="-1"
              placeholder-style="color:#999;font-size:28rpx" @confirm="searchAll"/>
            <image class='search_fd0_0_c1_c2' mode="aspectFit" :src='STATIC_URL+"196.png"' @tap="ClearInputFunc()"
              v-if=" keyword!=''"></image>
          </view>
        </view>

      </view>
      <view :style="{height: (100+StatusBarRpx)+'rpx'}"></view>
      <!---搜索记录flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout search_flex_1"
        v-if=" associateList.length==0 || keyword==''">
        <view class='flex flex-wrap align-center search_fd1_0'>
          <text class='search_fd1_0_c0'>历史搜索</text>
          <image class='search_fd1_0_c1' mode="aspectFit" :src='STATIC_URL+"197.png"'
            @tap.stop="popupShow1661481796822=true" v-if=" appSearchHistory.length>0"></image>
        </view>
        <view class='flex flex-wrap align-center search_fd1_1'>
          <template v-for='(item,key0) in appSearchHistory'>
            <view class='flex align-center search_fd1_1_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
              :data-url="`/pages/sy/tuijianshangjia/tuijianshangjia?keyword=${item.name}`"
              @longpress="handleLongpressFunc(item.name)" :key='key0'>
              <text class='search_fd1_1_c0_c0'>{{item.name}}</text>
              <image class='search_fd1_1_c0_c1' mode="aspectFit" :src='STATIC_URL+"198.png"'
                @tap.stop="deleteSearchHistoryFunc(item.name)" v-if=" item.name==removeIndex"></image>
            </view>
          </template>

        </view>
        <text class='search_fd1_2' v-if=" appSearchHistory.length==0">暂无历史记录</text>
      </view>

      <!---搜索记录flex布局结束-->
      <benben-popup v-model="popupShow1661481796822" :mask="true" :mask-close-able="true" mode='center'>
        <!---删除历史记录弹窗flex布局开始-->
        <view class="flex flex-direction flex-wrap align-center search_flex_2">
          <text class='search_fd2_0'>确定删除历史记录？</text>
          <view class='flex flex-wrap align-center search_fd2_1'>
            <button class='search_fd2_1_c0' @tap.stop="popupShow1661481796822=false">取消</button>
            <button class='search_fd2_1_c1' @tap.stop="emptySearchHistoryFunc()">确定</button>
          </view>
        </view>

        <!---删除历史记录弹窗flex布局结束-->

      </benben-popup>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction align-stretch benben-flex-layout" v-if=" associateList.length==0 || keyword==''">
        <view class='flex flex-wrap align-center search_fd3_0'>
          <text class='search_fd3_0_c0'>搜索发现</text>
        </view>
        <view class='flex flex-wrap align-center search_fd3_1'>
          <template v-for='(item,key0) in dataList'>
            <view class='flex flex-wrap align-center search_fd3_1_c0' @tap.stop="clickDiscoverFunc(item.name)"
              v-if="item.is_set=='0'" :key='key0'>
              <text class='search_fd3_1_c0_c0'>{{item.name}}</text>
            </view>
          </template>

        </view>
      </view>

      <!---flex布局flex布局结束-->
      <benben-popup v-model="popupShow1692100153978" :mask="true" :mask-close-able="true" mode='bottom'>
        <!---fxflex布局开始-->
        <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
          <view class='flex flex-direction flex-wrap align-stretch search_fd4_0'>
            <view class='flex flex-wrap align-center justify-between search_fd4_0_c0'>
              <view class='flex flex-wrap align-center search_fd4_0_c0_c0'>
              </view>
              <view class='flex flex-wrap align-center justify-center search_fd4_0_c0_c1'>
                <image class='search_fd4_0_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"481.png"'></image>
                <text class='search_fd4_0_c0_c1_c1'>分享到</text>
                <image class='search_fd4_0_c0_c1_c0' mode="aspectFit" :src='STATIC_URL+"480.png"'></image>
              </view>
              <view class='flex flex-wrap align-center search_fd4_0_c0_c2'>
                <image class='search_fd4_0_c0_c2_c0' mode="aspectFit" :src='STATIC_URL+"129.png"'
                  @tap="popupShow1692100153978=false"></image>
              </view>
            </view>
            <view class='flex flex-wrap align-center justify-around search_fd4_0_c1'>
              <view class='flex flex-direction flex-wrap align-center'>
                <image class='search_fd4_0_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"174.png"'></image>
                <text class='search_fd4_0_c1_c0_c1'>微信好友</text>
              </view>
              <view class='flex flex-direction flex-wrap align-center'>
                <image class='search_fd4_0_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"175.png"'></image>
                <text class='search_fd4_0_c1_c0_c1'>朋友圈</text>
              </view>
              <view class='flex flex-direction flex-wrap align-center'>
                <image class='search_fd4_0_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"94.png"'></image>
                <text class='search_fd4_0_c1_c0_c1'>复制链接</text>
              </view>
            </view>
          </view>
        </view>

        <!---fxflex布局结束-->

      </benben-popup>


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "popupShow1692100153978": false,
        "popupShow1661481796822": false,
        "keyword": "",
        "dataList": [],
        "dataLists": [],
        "removeIndex": -1,
        "xainshi": false,
        "associateList": [],
        "dataDetails": {
          "aid": "",
          "order_sn": "",
          "order_money": "",
          "payable_money": "",
          "coupon_id": "",
          "coupon_money": "",
          "send_time": "",
          "receive_time": "",
          "pay_time": "",
          "discount_money": "",
          "create_time": "",
          "pay_type": "",
          "status": "",
          "pay_type_str": "",
          "order_info": {
            "receiver_mobile": "",
            "receiver_address": "",
            "receiver_name": "",
            "remark": "",
            "province": "",
            "city": "",
            "district": "",
            "sex": "",
            "label_name": "",
            "express_price": "",
            "pickup_code": "",
            "pickup_img": ""
          },
          "order_goods_list": [],
          "shop_info": {
            "aid": "",
            "store_name": "",
            "store_logo": "",
            "store_logo_id": ""
          },
          "btn_list": {
            "cancel_order": "",
            "go_pay": "",
            "remind_send": "",
            "remind_already": "",
            "apply_invoice": "",
            "view_invoice": "",
            "apply_refund": "",
            "view_logistics": "",
            "confirm_receive": "",
            "evaluate": "",
            "delete_order": "",
            "pay_balance": ""
          },
          "is_multiple_package": "",
          "order_type": "",
          "advance_sn": "",
          "usermerchant_id": "",
          "discount_str": "",
          "surplus_receive_time": "",
          "group_info": {
            "join_timeout": "",
            "activity_status": "",
            "group_members_nums": "",
            "join_number": "",
            "status_txt": ""
          },
          "group_user": [],
          "real_money": "",
          "cancel_surplus_second": "",
          "balance_payment_stime": "",
          "balance_payment_etime": "",
          "receive_surplus_time": "",
          "goods_total": "",
          "pay_status": ""
        },
        "order_id": null,
        "order_sn": ""
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },
      appSearchHistory() { // 搜索历史
        return this.$store.state.appSearchHistory
      }
    },
    watch: {},
    onLoad(options) {
      let {
        order_id,
        order_sn
      } = options
      if (order_id !== undefined) this.order_id = order_id
      if (order_sn !== undefined) this.order_sn = order_sn
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //搜索
      async searchForFunc() {
        //请求方法
        //数据验证

        let datadataList = await this.$api.get(global.apiUrls.post641af9cb8b32f, {
          view_position: 'all'
        });

        if (datadataList.data.code != 1) {
          this.$message.info(datadataList.data.msg);
          return
        }
        let infodataList = datadataList.data;
        this.dataList = infodataList.data

      },
      //全网热搜
      async fullNetworkHotSearchFunc() {
        //请求方法
        //数据验证

        let datadataLists = await this.$api.get(global.apiUrls.post641afd26102ab, {

        });

        if (datadataLists.data.code != 1) {
          this.$message.info(datadataLists.data.msg);
          return
        }
        let infodataLists = datadataLists.data;
        this.dataLists = infodataLists.data

      },
      //换一批
      changeSweetGrilFunc() {
        this.$util.debounce(() => {
          this.searchForFunc();
        }, 300);
      },
      //长按事件
      handleLongpressFunc(index) {
        this.removeIndex = index;
      },
      searchAll(){
        if(!this.keyword){
          return;
        }
        this.$store.commit('appSearchHistoryAdd', {
          "name": this.keyword
        })
        this.$urouter.navigateTo(`/pages/sy/tuijianshangjia/tuijianshangjia?keyword=${this.keyword}&cid=`);
      },
      //添加搜索历史
      addSearchHistoryFunc(name) {
        if (this.keyword != '') {
          this.$store.commit('appSearchHistoryAdd', {
            "name": this.keyword
          })
          this.$urouter.navigateTo(`/pages/sy/tuijianshangjia/tuijianshangjia?keyword=${this.keyword}&cid=`);
        } else {
          this.$store.commit('appSearchHistoryAdd', {
            "name": name
          })
          this.$urouter.navigateTo(`/pages/sy/tuijianshangjia/tuijianshangjia?keyword=${name}&cid=`);
        }
      },
      //删除搜索历史
      deleteSearchHistoryFunc(name) {
        this.$store.commit('appSearchHistoryDel', {
          "name": name
        })
      },
      //清空搜索记录
      emptySearchHistoryFunc() {
        this.$store.commit('appSearchHistoryClean', '')
        this.popupShow1661481796822 = false;
      },
      //搜索框输入内容
      async searchFunc() {
        if (this.keyword != '') {
          //请求方法
          //数据验证

          let dataassociateList = await this.$api.aGet(global.apiUrls.post64184ac1cafc3, {
            keyword: this.keyword
          });

          if (dataassociateList.data.code != 1) {
            this.$message.info(dataassociateList.data.msg);
            return
          }
          let infoassociateList = dataassociateList.data.data;
          this.associateList = infoassociateList.data

          if (this.associateList.length != 0) {
            this.xainshi = true;
          }
        }
      },
      //清空输入框
      ClearInputFunc() {
        this.keyword = '';
      },
      //点击发现
      clickDiscoverFunc(name) {
        this.$store.commit('appSearchHistoryAdd', {
          "name": name
        })
        this.$urouter.navigateTo(`/pages/sy/tuijianshangjia/tuijianshangjia?keyword=${name}&cid=`);
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: var(--benbenbgColor1);
    background-size: 100% auto;
  }

  .search_flex_0 {
    background: var(--benbenbgColor1);
    width: 750rpx;
    height: 100rpx;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .search_fd0_0_c1_c2 {
    width: 28rpx;
    height: 28rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .search_fd0_0_c1_c1 {
    margin: 0rpx 0rpx 0rpx 16rpx;
  }

  .search_fd0_0_c1_c0 {
    width: 24rpx;
    height: 24rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .search_fd0_0_c1 {
    background: rgba(249, 249, 249, 1);
    background-size: 100% auto !important;
    border-radius: 34rpx 34rpx 34rpx 34rpx;
    margin: 0rpx 0rpx 0rpx 24rpx;
    padding: 0rpx 24rpx 0rpx 24rpx;
    height: 64rpx;
    width: 440rpx;
  }

  .search_fd0_0_c0 {
    font-size: 36rpx;
    color: #333;
    font-weight: 500;
    width:50rpx;
    height: 50rpx;
  }

  .search_fd0_0 {
    margin: 17rpx 32rpx 24rpx 32rpx;
  }

  .search_flex_1 {
    padding: 0rpx 0rpx 0rpx 0rpx;
  }

  .search_fd1_2 {
    font-size: 24rpx;
    font-weight: 400;
    color: #666666;
    margin: 0rpx 0rpx 32rpx 24rpx;
  }

  .search_fd1_1_c0_c1 {
    width: 18rpx;
    height: 18rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .search_fd1_1_c0_c0 {
    font-size: 24rpx;
    font-weight: 400;
    color: rgba(51, 51, 51, 1);
    margin: 0rpx 16rpx 0rpx 0rpx;
    -webkit-line-clamp: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    max-width: 200rpx;
  }

  .search_fd1_1_c0 {
    background: var(--benbenbgColor5);
    border-radius: 32rpx 32rpx 32rpx 32rpx;
    background-size: 100% auto !important;
    padding: 0rpx 40rpx 0rpx 40rpx;
    line-height: 56rpx;
    margin: 0rpx 12rpx 24rpx 12rpx;
  }

  .search_fd1_1 {
    padding: 0rpx 0rpx 0rpx 12rpx;
  }

  .search_fd1_0_c1 {
    width: 24rpx;
    height: 28rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx auto;
  }

  .search_fd1_0_c0 {
    font-size: 32rpx;
    font-weight: 500;
    color: rgba(51, 51, 51, 1);
  }

  .search_fd1_0 {
    padding: 32rpx 0rpx 24rpx 0rpx;
    margin: 0rpx 24rpx 0rpx 24rpx;
  }

  .search_flex_2 {
    background: var(--benbenbgColor1);
    margin: 0rpx 105rpx 0rpx 105rpx;
    background-size: #eee;
    border-radius: 25rpx 25rpx 25rpx 25rpx;
    padding: 40rpx 0rpx 0rpx 0rpx;
  }

  .search_fd2_1_c1 {
    background: var(--benbenbgColor1);
    line-height: 110rpx;
    border-radius: 0rpx 0rpx 16rpx 0rpx;
    font-size: 32rpx;
    color: var(--benbenFontColor5);
    width: 269rpx;
    height: 110rpx;
  }

  .search_fd2_1_c0 {
    border-right: 1px solid #EEEEEE;
    background: var(--benbenbgColor1);
    line-height: 110rpx;
    border-radius: 0rpx 0rpx 0rpx 16rpx;
    font-size: 32rpx;
    color: var(--benbenFontColor2);
    height: 110rpx;
    width: 270rpx;
  }

  .search_fd2_1 {
    border-top: 1px solid #eee;
  }

  .search_fd2_0 {
    font-size: 36rpx;
    font-weight: 700;
    line-height: 52rpx;
    color: #333333;
    margin: 40rpx 0rpx 39rpx 0rpx;
  }

  .search_fd3_1_c0_c0 {
    font-size: 24rpx;
    font-weight: 400;
    color: rgba(51, 51, 51, 1);
  }

  .search_fd3_1_c0 {
    background: rgba(248, 248, 248, 1);
    border-radius: 32rpx 32rpx 32rpx 32rpx;
    background-size: 100% auto !important;
    padding: 0rpx 40rpx 0rpx 40rpx;
    line-height: 56rpx;
    margin: 0rpx 12rpx 24rpx 12rpx;
  }

  .search_fd3_1 {
    padding: 0rpx 0rpx 0rpx 12rpx;
  }

  .search_fd3_0_c0 {
    font-size: 32rpx;
    font-weight: 500;
    color: #333333;
    line-height: 38rpx;
  }

  .search_fd3_0 {
    padding: 24rpx 0rpx 24rpx 0rpx;
    margin: 0rpx 24rpx 0rpx 24rpx;
  }

  .search_fd4_0_c1_c0_c1 {
    font-size: 24rpx;
    font-weight: 400;
    color: #333;
  }

  .search_fd4_0_c1_c0_c0 {
    width: 80rpx;
    height: 80rpx;
    border-radius: 40rpx 40rpx 40rpx 40rpx;
    margin: 0rpx 0rpx 16rpx 0rpx;
  }

  .search_fd4_0_c1 {
    padding: 0rpx 0rpx 58rpx 0rpx;
  }

  .search_fd4_0_c0_c2_c0 {
    width: 40rpx;
    height: 40rpx;
    border-radius: 20rpx 20rpx 20rpx 20rpx;
  }

  .search_fd4_0_c0_c2 {
    margin: 0rpx 2rpx 0rpx 0rpx;
  }

  .search_fd4_0_c0_c1_c1 {
    font-size: 32rpx;
    font-weight: 700;
    color: #333;
    margin: 0rpx 16rpx 0rpx 16rpx;
  }

  .search_fd4_0_c0_c1_c0 {
    width: 32rpx;
    height: 10rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .search_fd4_0_c0_c1 {
    padding: 40rpx 0rpx 48rpx 0rpx;
  }

  .search_fd4_0_c0_c0 {
    width: 40rpx;
  }

  .search_fd4_0_c0 {
    padding: 0rpx 13rpx 0rpx 0rpx;
  }

  .search_fd4_0 {
    background: var(--benbenbgColor1);
    background-size: 100% auto !important;
    border-radius: 24rpx 24rpx 0rpx 0rpx;
    padding: 0rpx 32rpx 0rpx 32rpx;
  }
</style>
